package com.lunasoft.dp;

import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Jierry
 * @version 2016/7/12.
 */
public class Client {
    public static void main(String[] args) throws Exception {
        AOPImpl impl = new AOPImpl();
        AOPHandler handler = new AOPHandler(impl);
        //handler.setFlag(null);
        Map<String,String> config = new HashMap<String, String>();
        config.put("transaction","true");
        handler.setFlag(config);
        //生成一个动态代理类，指定AOP接口的实现类为AOPImpl，同时指定代理类的执行handler

        //AOPImpl.class.getClassLoader()指
        AOP aop = (AOP) Proxy.newProxyInstance(AOPImpl.class.getClassLoader(), new Class<?>[] {AOP.class}, handler);
        aop.show("cloud");
        String result = aop.say("芝加哥09");
        System.out.println(result);
    }
}
